﻿using DomainModel.Abstract;
using DomainModel.Concrete;
using System.Web.Mvc;
using System;
using WebCore;
using WebCore.Caching;
using System.Collections.Generic;
using DomainModel.Entities;
using WebCore.ModelViews;

namespace WebController.Controllers
{
    public class SearchController: _baseController
    {
        private IEventsRepository _eventsRepository = new EventsRepository();

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Event(string q)
        {
            if (!string.IsNullOrEmpty(q))
            {
                var list = _eventsRepository.Search(q);

                // page info setup
                var resultsView = new ResultsView
                {
                    PageTitle = "Search",
                    QueryString = q
                };
                ViewData["ResultsView"] = resultsView;
                // return the related events data
                return View("EventsList", list);
            }
            else
            {
                return RedirectToAction("index", "event");
            }

        }
    }
}
